package tengxun.com.sunny.t3;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-->0){
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int C = scanner.nextInt();
            if(A<B && C%A==0){
                System.out.println("YES");
                continue;
            }
            int k;
            for(k = 1; k <= B; k++){
                if(A*k >= B){
                    break;
                }
            }
            A = A*k;
//            System.out.println(A+" "+B+" "+C);
            if(A%B == 0){
                if(C != 0)
                    System.out.println("NO");
                else
                    System.out.println("YES");
            }else{
                int cnt = 2;
                int diff = A%B;
                if(diff == C){
                    System.out.println("YES");
                }else {
                    int tmpdiff = A * cnt % B;
                    boolean flag = false;
                    while (tmpdiff != diff) {
//                        System.out.println(cnt+" "+tmpdiff);
                        if (tmpdiff == C){
                            flag = true;
                            break;
                        }
                        cnt++;
                        tmpdiff = A*cnt%B;
                    }
                    if(flag){
                        System.out.println("YES");
                    }else{
                        System.out.println("NO");
                    }
                }
//                int diff = A%B;
//                if(diff == C){
//                    System.out.println("YES");
//                }else {
//                    boolean flag = false;
//                    int cnt = 2;
//                    int tmpdiff = cnt*diff%B;
//                    while (tmpdiff != diff){
//                        if(tmpdiff == C){
//                            flag = true;
//                            break;
//                        }
//                        cnt++;
//                        tmpdiff = cnt*diff%B;
//                    }
//                    if(flag){
//                        System.out.println("YES");
//                    }else{
//                        System.out.println("NO");
//                    }
//                }
            }
        }

    }

}
